// 选择 |  类似于或者  从左向右进行匹配 匹配到之后直接输出结果
var reg1 = /html|css|js/g
// console.log(reg1.exec('Hello html hello css'));
// console.log(reg1.exec('Hello html hello css'));

// 分组
// var reg2 = /briupbriupbriup/
var reg2 = /(briup){3}/
// console.log(reg2.test('briupbriupbriup'));

// 捕获与引用
var regDate = /(\d{4})-(\d{2})-(\d{2})/
// console.log(regDate.test('2022-08-15'));
// console.log(RegExp.$1);
// console.log(RegExp.$2);
// console.log(RegExp.$3);

var reg = /((apple) is (a (fruit)))/
var str = "apple is a fruit"
reg.test(str) // true
// console.log(RegExp.$1); // apple is a fruit
// console.log(RegExp.$2); // apple
// console.log(RegExp.$3);// a fruit
// console.log(RegExp.$4);// fruit

// 引用
var reg4 = /(\w{3}) is \1/g
console.log(reg4.test('kid is dik'));
